package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPauseOrResetEngineeringOrderView;
import com.cloudsigns.factorymanager2.engineering.IView.IPublicationOrderAssignReceiveDetailView;
import com.cloudsigns.factorymanager2.engineering.bean.PublicationOrderDetailBean;
import com.cloudsigns.factorymanager2.engineering.model.IPauseOrResetEngineeringOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationOrderAssignReceiveDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.PauseOrResetEngineeringOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationOrderAssignReceiveDetailModel;

/**
 * Created by tony on 2018/5/17.
 */

public class PublicationOrderAssignReceiveDetailPresenter {
    private IPublicationOrderAssignReceiveDetailView view;
    private IPublicationOrderAssignReceiveDetailModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PublicationOrderAssignReceiveDetailPresenter(IPublicationOrderAssignReceiveDetailView view) {
        this.view = view;
        this.model = new PublicationOrderAssignReceiveDetailModel();
    }

    public void getPublicationOrderAssignReceiveDetail() {


        model.getPublicationOrderAssignReceiveDetail(view.getOrderId(), new PublicationOrderAssignReceiveDetailModel.OnPublicationOrderAssignReceiveDetailListener() {
            @Override
            public void getPublicationOrderAssignReceiveDetailSuccessed(final PublicationOrderDetailBean publicationOrderBean) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getPublicationOrderAssignReceiveDetailSuccessed(publicationOrderBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getPublicationOrderAssignReceiveDetailFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getPublicationOrderAssignReceiveDetailFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
